<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表页</title>
    <style>
        ul,
        li {

            list-style: none;
        }

        ul {
            display: flex;
            border: 1px solid red;
            justify-content: space-evenly;
            padding: 10px 0;
        }

        ul li {
            width: 24%;
            border: 1px solid #ccc;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px 0;
            cursor: pointer;

        }

        ul li img {
            width: 90%;
        }

        ul li p {
            width: 90%;
            margin: 5px;
        }
    </style>
</head>

<body>
    <ul id="goods">
        <!-- <li class="goods1"><img src="../images/g1.jpg">
            <p>姓名：阿联酋美女1号</p>
            <p>价格：20</p>
            <p>年龄：20</p>
        </li> -->
    </ul>

</body>
<script>
    let goodlist = [
        { id: 1, url: '../images/g1.jpg', name: '阿联酋美女1号', price: 1998, age: 20 },
        { id: 2, url: '../images/g2.jpg', name: '阿联酋美女2号', price: 98, age: 18 },
        { id: 3, url: '../images/g3.jpg', name: '阿联酋美女3号', price: 998, age: 22 },
        { id: 4, url: '../images/g4.jpg', name: '阿联酋美女4号', price: 9.8, age: 24 },
        { id: 5, url: '../images/g3.jpg', name: '阿联酋美女5号', price: 9888, age: 18 }
    ]

    let goods = document.getElementById('goods');

    goodlist.forEach(function (item) {
        goods.innerHTML += `<li class="goods1" id="${item.id}">
                            <img src="${item.url}">
                            <p>姓名：${item.name}</p>
                            <p>价格：${item.price}</p>
                            <p>年龄：${item.age}</p>
                        </li>`
    })


    let lis = document.querySelectorAll('li');

    for (let i = 0; i < goodlist.length; i++) {
        lis[i].onclick = function () {
            window.open('./02详情页.html?id=' + this.id)
        }
    }
</script>

</html>